package de.velvettear.squirrel.util;

import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;

public class AnimationHelper {


	private static Animation animation;
	
	public static void startAnimation(View view) {
		startAnimation(view, false);
	}
	
	public static void startAnimation(View view, boolean showView) {
		if (animation == null) {
			animation = new AlphaAnimation(1.0f, 0.25f);
			animation.setDuration(1500);
			animation.setInterpolator(new LinearInterpolator());
			animation.setRepeatCount(Animation.INFINITE);
			animation.setRepeatMode(Animation.REVERSE); 				
		}
		view.startAnimation(animation);		
		if (showView) {
			view.setVisibility(View.VISIBLE);
		}
	}
	
	public static void stopAnimation(View view) {
		stopAnimation(view, false);
	}
	
	public static void stopAnimation(View view, boolean hideView) {
		if (animation != null) {
			animation.cancel();
		}
		view.clearAnimation();
		if (hideView) {
			view.setVisibility(View.GONE);
		}
	}
	
}
